import { cardsTable } from "./database/cards-table";
import { herosTable, HerosTableRegisterParams } from "./database/heros-table";
import { skillsTable } from "./database/skills-table";
import { skinsTable } from "./database/skins-table";
import { expressInit } from "./helpers/express-initializer";
import { socketServerInit } from "./services/socket-server";
import { Card } from "./types/Card";
import skin_data from "./assets/data/skin_data.json";
import skill_data from "./assets/data/skill_data.json";
import hero_data from "./assets/data/hero_data.json";
import hand_data from "./assets/data/hand_data.json";

process.on("uncaughtException", (err) => {
	console.error("Caught exception:", err);
	process.exit(1);
});
process.on("unhandledRejection", (reason, promise) => {
	console.error("Unhandled Rejection at:", promise, "Reason:", reason);
});
expressInit();
socketServerInit();
skin_data.forEach((v) => skinsTable.register(v));
skill_data.forEach((v) => skillsTable.register(v));
(hero_data as HerosTableRegisterParams[]).forEach((v) => herosTable.register(v));
(hand_data as Card[]).forEach((v) => cardsTable.register(v));
